package com.mh.zookeeper;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author meng.han
 * @since 2021-12-21
 */
public class PropertiesUtils {

    private static Properties zooConfig;

    static {
        ClassLoader classLoader = PropertiesUtils.class.getClassLoader();
        zooConfig = new Properties();
        try (InputStream inputstream = classLoader.getResourceAsStream("zoo-config.properties")) {
            zooConfig.load(inputstream);
        } catch (IOException e) {
            throw new RuntimeException("读取Zookeeper配置异常");
        }
    }

    public static String getProperty(String key) {
        return zooConfig.getProperty(key);
    }

    public static String getZookeeperConnectStr() {
        return getProperty("zookeeper.address");
    }
}
